customize_validate_{$this->id}
Filter HookDescription
Validates a Customize setting value. Plugins should amend the `$validity` object via its `WP_Error::add()` method. The dynamic portion of the hook name, `$this->ID`, refers to the setting ID.Hook Information
File Location |
wp-includes/class-wp-customize-setting.php
View on GitHub
|
Hook Type | Filter |
Line Number | 617 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Error
|
$validity
|
Filtered from `true` to `WP_Error` when invalid. |
mixed
|
$value
|
Value of the setting. |
WP_Customize_Setting
|
$setting
|
WP_Customize_Setting instance. |
Usage Examples
Basic Usage
<?php
// Hook into customize_validate_{$this->id}
add_filter('customize_validate_{$this->id}', 'my_custom_filter', 10, 3);
function my_custom_filter($validity, $value, $setting) {
// Your custom filtering logic here
return $validity;
}
Source Code Context
wp-includes/class-wp-customize-setting.php:617
- How this hook is used in WordPress core
<?php
612 *
613 * @param WP_Error $validity Filtered from `true` to `WP_Error` when invalid.
614 * @param mixed $value Value of the setting.
615 * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
616 */
617 $validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this );
618
619 if ( is_wp_error( $validity ) && ! $validity->has_errors() ) {
620 $validity = true;
621 }
622 return $validity;
PHP Documentation
<?php
/**
* Validates a Customize setting value.
*
* Plugins should amend the `$validity` object via its `WP_Error::add()` method.
*
* The dynamic portion of the hook name, `$this->ID`, refers to the setting ID.
*
* @since 4.6.0
*
* @param WP_Error $validity Filtered from `true` to `WP_Error` when invalid.
* @param mixed $value Value of the setting.
* @param WP_Customize_Setting $setting WP_Customize_Setting instance.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/class-wp-customize-setting.php
Related Hooks
Related hooks will be displayed here in future updates.